<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>05.offset和position方法</title>
</head>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        .father {
            width: 400px;
            height: 400px;
            background-color: pink;
            position: relative;
            margin: 100px;
        }
        .son {
            width: 200px;
            height: 200px;
            background-color: #232323;
            position: absolute;
            top: 100px;
            left: 100px;
        }
    </style>
<body>
    
    <div class="father">
        <div class="son"></div>
    </div>
    
    <script src="../jquery-3.2.1.js"></script>
    <script>
    
        $(function(){
            // 获取元素的相对于doxument的位置
           console.log( $(".son").offset())
           // 获取元素相对于有定位的父元素的位置
           console.log( $(".son").position())
           console.log( $(".son").position().left )
        });
    
    </script>
</body>
</html>